package com.wanxi.generictype.treeset1;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class TreeSetSort {
    public static void main(String[] args) {
        Student student1 = new Student("陈明", 28);
        Student student2 = new Student("王海云", 25);
        Student student3 = new Student("江明", 28);
        Student student4 = new Student("刘大姐", 29);
        Student student5 = new Student("后悔", 30);
        Student student6 = new Student("钟鸣一", 32);
        Student student7 = new Student("AB", 28);
        Student student8 = new Student("AA", 28);
        Student student9 = new Student("BB", 28);

//测试自然排序法。
        Set set = new TreeSet();

        set.add(student1);
        set.add(student2);
        set.add(student3);
        set.add(student4);
        set.add(student5);
        set.add(student6);
        set.add(student7);
        set.add(student8);
        set.add(student9);


//        System.out.println(set);

        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }


    }
}
